# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=bzrtp
pkgver=5.2.86
pkgrel=1
pkgdesc="BZRTP is an opensource implementation of ZRTP keys exchange protocol"
url="https://gitlab.linphone.org/BC/public/bzrtp"
arch="all"
license="GPL-3.0-only"
makedepends="cmake bctoolbox-dev sqlite-dev libxml2-dev samurai"
subpackages="$pkgname-dev"
source="https://gitlab.linphone.org/BC/public/bzrtp/-/archive/$pkgver/bzrtp-$pkgver.tar.gz"
options="!check" # need bctoolbox-tester

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DENABLE_STATIC=False \
		-DENABLE_STRICT=False \
		-DENABLE_TESTS="$(want_check && echo ON || echo OFF)" \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
f51a9bbd7de68160a37b6037239bbafbf40d0f1921b418b978eaf51d82a90a502ccf86a3a6e57ba856b642023c41c48761a7759b1fdc7f1e0db7d7bcd7c6dd53  bzrtp-5.2.86.tar.gz
"
